package com.lzh.cli.example;

import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.Parameters;

/**
 * picocli快速入门示例
 *
 * @author lzh
 * @version 1.0
 * @date 2025/3/30
 */
@Command(name = "ASCIIArt", version = "ASCIIArt 1.0", mixinStandardHelpOptions = true)
// mixinStandardHelpOptions = true 可以给应用程序自动添加--help和--version选项
public class ASCIIArt implements Runnable {

    @Option(names = {"-s", "--font-size"}, description = "Font size") // 命令行选项
    int fontSize = 19;

    @Parameters(paramLabel = "<word>", defaultValue = "Hello, picocli",
            description = "Words to be translated into ASCII art.") // 命令行参数
    private String[] words = {"Hello,", "picocli"};

    @Override
    public void run() {
        // 自己实现业务逻辑（当命令解析成功，用户敲了回车后被调用）
        System.out.println("fontSize = " + fontSize);
        System.out.println("words = " + String.join(",", words));
    }

    public static void main(String[] args) {
//         args = new String[] {"--help"};
//         args = new String[] {"--version"};
         args = new String[] {"-s", "12", "lzh", "lzh1", "lzh2"};
        // 返回一个退出代码
        int exitCode = new CommandLine(new ASCIIArt()).execute(args);
        System.exit(exitCode);
    }
}
